<template>
  <div>
    <el-card class="box-card">
      <el-row>
        <el-col :span="5" class="labClass">
          <div class="grid-content bg-purple">
            <span>供应商名称:</span>
          </div>
        </el-col>
        <el-col :span="16">
          <div class="grid-content bg-purple-light">
            <span style="margin-right: 290px">{{supplierName}}</span>
          </div>
        </el-col>
        <el-col :span="3" class="labClass">
          <div class="grid-content bg-purple">
          </div>
        </el-col>
      </el-row>
      <br>
      <p/>
      <el-row>
        <el-col :span="5" class="labClass">
          <div class="grid-content bg-purple">
            <span>负责人:</span>
          </div>
        </el-col>
        <el-col :span="16">
          <div class="grid-content bg-purple-light">
            <el-input v-model="supplierUser" placeholder="负责人"></el-input>
          </div>
        </el-col>
        <el-col :span="3" class="labClass">
          <div class="grid-content bg-purple">
          </div>
        </el-col>
      </el-row>
      <p/>
      <br>
      <p/>
      <el-row>
        <el-col :span="5" class="labClass">
          <div class="grid-content bg-purple">
            <span>负责人电话:</span>
          </div>
        </el-col>
        <el-col :span="16">
          <div class="grid-content bg-purple-light">
            <el-input v-model="supplierPhone" placeholder="负责人电话"></el-input>
          </div>
        </el-col>
        <el-col :span="3" class="labClass">
          <div class="grid-content bg-purple">
          </div>
        </el-col>
      </el-row>
      <p/>
      <br>
      <p/>
      <el-row>
        <el-col :span="5" class="labClass">
          <div class="grid-content bg-purple">
            <span>供应商地址:</span>
          </div>
        </el-col>
        <el-col :span="16">
          <div class="grid-content bg-purple-light">
            <span style="margin-right: 290px">{{supplierAddress}}</span>
          </div>
        </el-col>
        <el-col :span="3" class="labClass">
          <div class="grid-content bg-purple">
          </div>
        </el-col>
      </el-row>
      <p/>
      <br>
      <p/>
      <el-row>
        <el-col :span="5" class="labClass">
          <div class="grid-content bg-purple">
            <span>经营范围:</span>
          </div>
        </el-col>
        <el-col :span="16">
          <div class="grid-content bg-purple-light">
            <span style="margin-right: 290px">{{supplierScope}}</span>
          </div>
        </el-col>
        <el-col :span="3" class="labClass">
          <div class="grid-content bg-purple">
          </div>
        </el-col>
      </el-row>
      <p/>

      <el-button type="success" @click="update">修改</el-button>
    </el-card>

  </div>
</template>

<script>
export default {
  name: "updateSupplier",
  data() {
    return {
      supplierId:0,
      supplierName: '',
      supplierUser: '',
      supplierPhone: '',
      supplierAddress: '',
      supplierScope: ''
    }
  },
  methods:{
    init(id){
      this.supplierId=id;
      let params = {
        supplierId:id
      }
      this.$axios.get('drp/supplier/findById', {params: params}).then(
          r => {
            this.supplierName=r.data.supplierName
            this.supplierUser=r.data.supplierUser
            this.supplierPhone=r.data.supplierPhone
            this.supplierAddress=r.data.supplierAddress
            this.supplierScope=r.data.supplierScope
          }
      )
    },
    update(){
      let formData = new FormData()
      formData.append("supplierId", this.supplierId)
      formData.append("supplierUser", this.supplierUser)
      formData.append("supplierPhone", this.supplierPhone)
      this.$axios.post('drp/supplier/updateSupplierUserAndPhone', formData).then(
          r => {
            if (r.data=='ok'){
              location.href="/index"
            }else {
              this.$message.error("更改失败")
            }
          }
      )
    }
  }
}
</script>

<style scoped>

</style>